/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
struct ListNode* removeElements(struct ListNode* head, int val) {
  while  (head!=NULL&&head->val==val)
    {
        head=head->next;
    }
   struct  ListNode* tip=head;
   struct  ListNode* move=head;     //不是move=head->next，不然会访问空指针的成员变量
    while (move!=NULL)
    {
        if (move->val==val)
        {  
            tip->next=move->next;
        }
        else
        {
        tip=move;
        }
        move=move->next;
    }
    return head;
}
